package common;

public final class Area {
	{
		Location = new Coordinate();
		Boundary = new Rectangle();
	}
	public Area() {
	}
	public Area(Rectangle boundary) {
		boundary.copyTo(Boundary);
	}
	public Area(Coordinate location, Rectangle boundary) {
		setLocation(location);
		boundary.copyTo(Boundary);
	}
	public final Coordinate Location;
	public final Rectangle Boundary;
	
	public void translate(int x, int y) {
		Location.X += x;
		Location.Y += y;
	}
	public void translate(Coordinate offset) {
		if(offset != null) {
			Location.X += offset.X;
			Location.Y += offset.Y;
		}
	}
	public void setLocation(int x, int y) {
		Location.X = x;
		Location.Y = y;
	}
	public void setLocation(Coordinate location) {
		if(location != null) {
			Location.X = location.X;
			Location.Y = location.Y;
		}
	}
	public void setboundary(int x, int y, int width, int height) {
		Boundary.X = x;
		Boundary.Y = y;
		Boundary.Width = width;
		Boundary.Height = height;
	}
	public void setboundary(Rectangle boundary) {
		if(boundary != null) {
			boundary.copyTo(boundary);
		}
	}
	public Rectangle getTranslated() {
		return new Rectangle(Boundary.X + (int)Location.X, Boundary.Y + (int)Location.Y, Boundary.Width, Boundary.Height);
	}
	public boolean overlaps(Area other) {
		return (this.getTranslated().overlaps(other.getTranslated()));
	}
	public boolean overlaps(Rectangle other) {
		return (this.getTranslated().overlaps(other));
	}
	public boolean contains(Area other) {
		return (this.getTranslated().contains(other.getTranslated()));
	}
	public boolean contains(Rectangle other) {
		return (this.getTranslated().contains(other));
	}
	public void copyTo(Area other) {
		Location.copyTo(other.Location);
		Boundary.copyTo(other.Boundary);
	}
	public Area clone() {
		return new Area(Location, Boundary);
	}
	@Override
	public String toString() {
		return Location.toString() + ":" + Boundary.toString();
	}
}